home *** CD-ROM | disk | FTP | other *** search
/ The Video Game Solution CD / The VideoGame Solution CD.iso / extra / pro56 / uwc.c < prev    next >
Encoding:
C/C++ Source or Header  |  1992-04-07  |  3.6 KB  |  164 lines

  1. /* UnderWorldCheat (uwc.exe) */
  2.  
  3. /* i never write comments unless i'm getting paid */
  4.  
  5. #include <stdio.h>
  6. #include <conio.h>
  7. #include <string.h>
  8. #include <io.h>
  9. #include <math.h>
  10.  
  11. int main()
  12. {
  13.  
  14.    typedef struct {
  15.       char desc[11];
  16.       int offst;
  17.       unsigned char val;
  18.    } oneline;
  19.  
  20.    oneline dat[27];
  21.    char pad[23],name[13];
  22.    FILE *in,*out;
  23.    unsigned char xx,yy;
  24.    int i,x,choice;
  25.  
  26.    for (i=1;i<=3;++i) dat[i-1].offst=i+30;
  27.    dat[3].offst=55;
  28.    dat[4].offst=57;
  29.    dat[5].offst=62;
  30.    for (i=6;i<=25;++i) dat[i].offst=i+28;
  31.    strcpy(dat[0].desc,"Str");
  32.    strcpy(dat[1].desc,"Dex");
  33.    strcpy(dat[2].desc,"Int");
  34.    strcpy(dat[3].desc,"Vit (max)");
  35.    strcpy(dat[4].desc,"Mana (max)");
  36.    strcpy(dat[5].desc,"Level");
  37.    strcpy(dat[6].desc,"Attack");
  38.    strcpy(dat[7].desc,"Defense");
  39.    strcpy(dat[8].desc,"Unarmed");
  40.    strcpy(dat[9].desc,"Sword");
  41.    strcpy(dat[10].desc,"Axe");
  42.    strcpy(dat[11].desc,"Mace");
  43.    strcpy(dat[12].desc,"Missile");
  44.    strcpy(dat[13].desc,"Mana");
  45.    strcpy(dat[14].desc,"Lore");
  46.    strcpy(dat[15].desc,"Casting");
  47.    strcpy(dat[16].desc,"Traps");
  48.    strcpy(dat[17].desc,"Search");
  49.    strcpy(dat[18].desc,"Track");
  50.    strcpy(dat[19].desc,"Sneak");
  51.    strcpy(dat[20].desc,"Repair");
  52.    strcpy(dat[21].desc,"Charm");
  53.    strcpy(dat[22].desc,"Picklock");
  54.    strcpy(dat[23].desc,"Acrobat");
  55.    strcpy(dat[24].desc,"Appraise");
  56.    strcpy(dat[25].desc,"Swimming");
  57.  
  58.    if ((in=fopen("player.dat","rb"))==NULL)
  59.       {
  60.      fprintf(stderr,"\nCannot open input file (player.dat).\n");
  61.      printf("Put this program in one of the UW save directories\n");
  62.      printf("i.e. SAVE1,SAVE2,SAVE3, or SAVE4.\n");
  63.      printf("This program is looking for the file 'player.dat'\n");
  64.      return 1;
  65.       }
  66.  
  67.    tmpnam(name);
  68.  
  69.    if ((out=fopen(name,"w+b")) == NULL)
  70.       {
  71.      fprintf(stderr,"Cannot open output file.\n");
  72.      return 1;
  73.       }
  74.  
  75.    xx=fgetc(in);
  76.    yy=0;
  77.  
  78.    while(!feof(in))
  79.    {
  80.       fputc(yy^xx,out);
  81.       xx=xx+3;
  82.       yy=fgetc(in);
  83.    }
  84.    fclose(in);
  85.  
  86.    for(i=0;i<=25;++i)
  87.    {
  88.       fseek(out,dat[i].offst,SEEK_SET);
  89.       dat[i].val=fgetc(out);
  90.    }
  91.  
  92.    choice=-1;
  93.    do
  94.    {
  95.       if ( !((choice>25)||(choice<0)) )
  96.       {
  97.      printf("Change '%s' to ->",dat[choice].desc);
  98.      scanf("%d",&i);
  99.      if(i>255)i=255;
  100.      if(i<0)i=0;
  101.      fflush(stdin);
  102.      dat[choice].val=i;
  103.       }
  104.  
  105.       printf("\n\n\n\n");
  106.       printf("Personal Statistics:\n");
  107.       for(i=0;i<=5;++i)
  108.       {
  109.      printf ("%2d: %10s=%3d  \n",i,dat[i].desc,dat[i].val);
  110.       }
  111.       x=1;
  112.       printf("Skills:\n");
  113.  
  114.       for(i=6;i<=25;++i)
  115.       {
  116.      printf ("%2d: %10s=%3d                ",i,dat[i].desc,dat[i].val);
  117.      x=x^1;
  118.      if(x==1)printf("\n");
  119.       }
  120.  
  121.       printf("\nChange which number? (26 to stop editing) ->");
  122.       scanf("%d",&choice);
  123.       fflush(stdin);
  124.    } while (choice != 26);
  125.  
  126.    printf("\nType 's' to save or anything else to abort ->");
  127.    xx=getc(stdin);
  128.  
  129.    if ((xx=='s')||(xx=='S'))
  130.    {
  131.       printf("Save..");
  132.       remove("player.bak");
  133.       rename("player.dat","player.bak");
  134.       for(i=0;i<=25;++i)
  135.       {
  136.      fseek(out,dat[i].offst,SEEK_SET);
  137.      fputc(dat[i].val,out);
  138.       }
  139.       in=fopen("player.dat","w+b");
  140.       fseek(out,0,SEEK_SET);
  141.       xx=fgetc(out);
  142.       yy=0;
  143.       while(!feof(out))
  144.       {
  145.      fputc(yy^xx,in);
  146.      xx=xx+3;
  147.      yy=fgetc(out);
  148.       }
  149.       fclose(in);
  150.       fclose(out);
  151.       remove(name);
  152.       printf("done!\n");
  153.    }
  154.    else
  155.    {
  156.       printf("Don't save\n");
  157.       fclose(out);
  158.       remove(name);
  159.    }
  160.  
  161. /*You cheat like a Stygian lizard man */
  162.  
  163.    return 0; /* END (uwc) */
  164. }